package cn.itcast.base;

import cn.itcast.domain.User;
import org.springframework.web.bind.annotation.ModelAttribute;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

public class BaseController {

    public HttpServletRequest request;
    public HttpServletResponse response;
    public HttpSession session;

    public String company_id;
    public String company_name;
    public User user;

    @ModelAttribute
    public void init(HttpServletRequest request, HttpSession session, HttpServletResponse response){
        this.request=request;
        this.response=response;
        this.session=session;

        User loginUser =(User)session.getAttribute("loginUser");
        if(loginUser!=null){
            this.company_id=loginUser.getCompanyId(); //后期改成当前登录用户的
            this.company_name=loginUser.getCompanyName(); //后期改成当前登录用户的
        }

        this.user=loginUser;

    }
}
